/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.assg2.dao;

import com.movie.Cinema;
import com.movie.Movie;
import java.util.List;
import org.hibernate.Query;

/**
 *
 * @author alexnewski
 */
public class DaoCinema extends GenericDao {

    public DaoCinema() {
        super(Cinema.class);
    }
    
    public List<Cinema> findByMovie(Movie m){
        Query q = query("select distinct c from Cinema c, Movie m, Show s, Room r where c.idcinema=r.cinemaIdcinema and r.idroom=s.roomIdroom and s.movieIdmovie=m.idmovie and m.idmovie=" + Integer.toString(m.getIdmovie()));
        if (!q.list().isEmpty()) {
            return q.list();
        } else {
            return null;
        }
    }
    
    
}
